'use strict'

const isNumber = {
    validator(rule, value, callback, source, options) {
        if (!isNaN(value)) {
            return callback()
        }
        callback({ message: '只能为数字' })
    }
}

module.exports = {
    type: [
        { required: true, message: 'type不能为空' },
        {
            validator(rule, value, callback, source, options) {
                const pattern = /^(html5|video|poster|longImage|测试分类)$/
                if (pattern.test(value)) {
                    return callback()
                }
                callback({ message: '想要获取的列表类型不正确(html5|video|poster|longImage|测试类型)' })
            }
        }
    ],
    pageSize: [
        { ...isNumber }
    ],
    pageNow: [
        { ...isNumber }
    ]
}